//封装category相关的接口函数

import request from '@/utils/request'

export const getTopCategoryService = (id) => {
    return request({
        url: '/category',
        method: 'GET',
        params: {
            id
        }
    })
}

export const getCategoryFilterService = (id) => {
    return request({
        url: '/category/sub',
        method: 'GET',
        params: {
            id
        }
    })
}

export const getSubCategoryService = (data) => {
    return request({
        url: '/category/goods/temporary',
        method: 'POST',
        data
    })
}

export const getGoodFilterService = ({name,page = 1,pageSize = 5}) => {
    return request({
        url: '/category/search',
        method: 'GET',
        params:{
            name,
            page,
            pageSize
        }
    })
}

export const getSubCategoryListService = () => {
    return request({
        url: '/category/sub/list',
        method: 'GET'
    })
}

export const getCategoryAllListService = () => {
    return request({
        url: '/category/alllist',
        method: 'GET'
    })
}

export const getCategoryListService = (params) => {
    return request({
        url: '/category/list',
        method: 'GET',
        params
    })
}

export const addCategoryService = (data) =>{
    return request({
        url: '/category/add',
        method: 'POST',
        data
    })
}

export const updateCategoryService = (data) =>{
    return request({
        url: '/category/update',
        method: 'PUT',
        data
    })
}

export const deleteCategoryService = (id) =>{
    return request({
        url: '/category/delete?id='+id,
        method: 'DELETE'
    })
}

export const getSubCategoryPageListService = (params) => {
    return request({
        url: '/category/sub/pagelist',
        method: 'GET',
        params
    })
}

export const addSubCategoryService = (data) =>{
    return request({
        url: '/category/sub/add',
        method: 'POST',
        data
    })
}

export const updateSubCategoryService = (data) =>{
    return request({
        url: '/category/sub/update',
        method: 'PUT',
        data
    })
}

export const deleteSubCategoryService = (id) =>{
    return request({
        url: '/category/sub/delete?id='+id,
        method: 'DELETE'
    })
}
